#include <iostream>
#include <kuai/mol/ct.hpp>

#include "kuaikan.h"

using namespace kuai;


KUAIKAN_API(BigSize) getConnectTableSize(Index nAtoms, Index nBonds) {
	return ConnectTable::buffer_size(nAtoms, nBonds);
}

KUAIKAN_API(void) makeConnectTable(const Index input[], Index buffer[]) {
	ConnectTable::makeBuffer(input, buffer);
}

KUAIKAN_API(void) molRegion(Index nAtoms, const XYZ coords[], XYZ result[]) 
{
	if (nAtoms > 0) {
		result[0] = result[1] = coords[0];
		for (Index i = 1; i < nAtoms; ++i) {
			if (coords[i].x < result[0].x) {
				result[0].x = coords[i].x;
			}
			else if (coords[i].x > result[1].x) {
				result[1].x = coords[i].x;
			}
			if (coords[i].y < result[0].y) {
				result[0].y = coords[i].y;
			}
			else if (coords[i].y > result[1].y) {
				result[1].y = coords[i].y;
			}
			if (coords[i].z < result[0].z) {
				result[0].z = coords[i].z;
			}
			else if (coords[i].z > result[1].z) {
				result[1].z = coords[i].z;
			}
		}
	}
}

KUAIKAN_API(void) bondBiasVector(Index ctdata[], const XYZ coords[], XYZ result[]) 
{
	ConnectTable ct(ctdata);


}

